from pydantic import BaseModel, Field, ConfigDict

class StudentCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=50)
    gender: str = Field(..., pattern="^(男|女|未知)$")
    height: int
    weight: float
    hobby: str = Field(..., pattern="^(打球|运动|逛街|聊天|阅读|吃饭|游戏|其他)$")

class StudentResp(StudentCreate):
    id: int
    model_config = ConfigDict(from_attributes=True)

# 追加
class OptionResp(BaseModel):
    opkey: str
    opvalue: str
    model_config = ConfigDict(from_attributes=True)

class OptionKey(BaseModel):
    opkey: str

class CheckIsRightRsp(BaseModel):
    id: int
    stuid: int
    isright: bool
    model_config = ConfigDict(from_attributes=True)

class CheckIsRightUpdate(BaseModel):
    stuid: int
    isright: int = Field(..., ge=0, le=1)   # 只允许 0/1